<template>
    <div class="demo-collapse">
        <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="问题描述" name="des">
                <div class="detail">
                    <img class="image" src="../../../../../assets/硬币找零/硬币找零2.jpg">
                    <div class="detail-text">
                        <div class="text">
                            给定 n 种不同面值的硬币，分别记为 c[0], c[1], c[2], … c[n]，
                            同时还有一个总金额 k，编写一个函数计算出最少需要几枚硬币凑出这个金额 k？
                        </div>
                        <el-table :data="tableData" border style="width: 99%;">
                            <el-table-column prop="name" label="名称" />
                            <el-table-column prop="time" label="时间复杂度" />
                            <el-table-column prop="spatial" label="空间复杂度" />
                        </el-table>
                    </div>
                </div>
            </el-collapse-item>
            <el-collapse-item title="相关研究" name="3">
                <ul>
                    <li v-for="item in thesisData" :key="item.title">
                        <a :href="item.link" target="_blank">
                            <div class="thesis">
                                <img class="thesis-cover" src="../../../../../icons//thesis.svg" alt="">
                                <div class="thesis-title">
                                    {{ item.title }}
                                </div>
                                <div class="thesis-author">
                                    <span>作者：</span>{{ item.author }}
                                </div>
                                <div class="thesis-time">
                                    <span>时间：</span>{{ item.time }}
                                </div>
                                <div class="thesis-source">
                                    <span>来源：</span>{{ item.source }}
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </el-collapse-item>
            <el-collapse-item title="应用场景" name="4">
                <div class="detail">
                    <img class="use" src="../../../../../assets/硬币找零/硬币找零.jpg" alt="">
                    <div class="text">
                        移动支付已经成为了我们日常生活当中的主流支付方式，无论是在便利店购买一瓶水，
                        还是在超市或菜市场购买瓜果蔬菜等生活用品，无处不在的二维码让我们的支付操作变得异常便捷。<br>
                        但在移动支付成为主流支付方式之前，我们常常需要面对一个简单问题，就是找零的问题。<br>
                        虽然说硬币找零在日常生活中越来越少，但它仍然活跃在编程领域和面试问题当中，主要还是因为它极具代表性，
                        也能多方面考察一个开发人员或面试者解决问题的能力。
                    </div>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const activeNames = ref(['1'])
const handleChange = (val: string[]) => {
    console.log(val)
}

// 相关研究部分
const thesisData = [
    {
        title: "贪心算法的探讨与研究",
        author: "常友渠，肖贵元，曾敏",
        time: "2008年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=b2529061ee063ecd1cc2d9992b465a2d&site=xueshu_se",
    },
    {
        title: "从贪心算法开始认识动态规划——硬币找零问题",
        author: "Mr.郑先生_",
        time: "2020年",
        source: "CSDN",
        link: "https://blog.csdn.net/zbp_12138/article/details/108909707",
    },
    {
        title: "python算法之贪心算法（硬币找零问题）",
        author: "黎明之道",
        time: "2020年",
        source: "CSDN",
        link: "https://blog.csdn.net/sjjsaaaa/article/details/106932401",
    },

]

// 复杂度表格描述
const tableData = [
    {
        name: '硬币找零问题',
        time: 'O(nlogn)',
        spatial: 'O(nlogn)',
    },
]
</script>

<style scoped lang="scss">
* {
    list-style: none;
}

.image {
    width: 290px;
    border-radius: 10px;
    margin-right: 10px;
}

a {
    text-decoration: none;
    /* 去除默认的下划线 */
    outline: none;
    /* 去除旧版浏览器的点击后的外虚线框 */
    color: #000;
    /* 去除默认的颜色和点击后变化的颜色 */
}

.detail {
    display: flex;
    justify-content: center;
    align-items: end;

    .detail-box {
        display: flex;
        flex-direction: column;
    }

    .text {
        margin-left: 10px;
        margin-bottom: 10px;
        cursor: default;
    }

    .use {
        width: 240px;
        height: 150px;
        border-radius: 10px;
    }
}

// 相关研究部分
.thesis {
    width: 98%;
    position: relative;
    left: 20px;
    margin-bottom: 10px;
    font-weight: normal;
    background: #F5F5F5;
    border-radius: 10px;
    transition: all 0.2s linear;

    .thesis-title {
        position: absolute;
        top: 0;
        left: 5px;
    }

    .thesis-author {
        position: absolute;
        top: 25px;
        left: 120px;
    }

    .thesis-time {
        position: absolute;
        top: 45px;
        left: 120px;
    }

    .thesis-source {
        position: absolute;
        top: 65px;
        left: 120px;
    }

    &:hover {
        cursor: pointer;
        transform: translateX(-15px);
    }
}
</style>